package Ex3;

import java.util.ArrayList;
import java.util.Iterator;

public class IntegerHashMap<V> implements Map<Integer, V> {
	// Note: V must have an equals method that compares on the value of the key.
	
	private final int CAPACITY = 11;
	private int size;
	private ArrayList<Entry<Integer, V>>[] table;
	
	@SuppressWarnings("unchecked")
	public IntegerHashMap() {
		size = 0;
		table = (ArrayList<Entry<Integer, V>>[]) new ArrayList[CAPACITY];
	}
	
	private int h(Integer key) {
		return key % CAPACITY;
	}
	
	@Override
	public V get(Integer k) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean isEmpty() {
		return size == 0;
	}

	@Override
	public Iterator<Integer> keys() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public V put(Integer k, V v) {
		int i = table[h(k)].indexOf(new Entry<Integer, V>(k,null));
		Entry<Integer,V> oldValue = null;
		if (i >= 0)
			oldValue = table[h(k)].get(i);
		
		table[h(k)].add(new Entry<Integer, V>(k,v));
		
		return oldValue.getV();
	}

	@Override
	public V remove(Integer k) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int size() {
		return size;
	}

	@Override
	public Iterator<V> values() {
		// TODO Auto-generated method stub
		return null;
	}
	
}
